import * as PIXI from 'pixi.js'
import param, { getDividing } from '../param'
import rank from './rank'
import type from './type'
import category from './category'
import element from './element'
import series from './series'
import input from './input'
import btns from './btns'

/** 横向分割线 */
const horizontalDividing = async (): Promise<PIXI.Sprite> => {
  const sprite = await getDividing(0)
  sprite.position.set(param.value.leftUsageWidth / 2, param.value.startHeight + param.value.leftUsageHeight - 13)
  return sprite
}
const verticalDividing = async (): Promise<PIXI.Sprite> => {
  const sprite = await getDividing(Math.PI / 2)
  sprite.position.set(param.value.leftUsageWidth + 10, param.value.height / 2)
  return sprite
}
export default async (): Promise<PIXI.Container<PIXI.ContainerChild>> => {
  const container = new PIXI.Container()
  const elementContainer = await element() // 元素(放到第一个, 确定横方向占位)
  container.addChild(await horizontalDividing())
  const rankContainer = await rank() // 品阶
  container.addChild(await horizontalDividing())
  const seriesContainer = await series() // 系列
  container.addChild(await horizontalDividing())
  const typeContainer = await type() // 类型
  container.addChild(await horizontalDividing())
  const categoryContainer = await category() // 类别
  container.addChild(await horizontalDividing())
  const btnsContainer = await btns() // 按钮
  container.addChild(await verticalDividing())
  container.addChild(typeContainer)
  container.addChild(categoryContainer)
  container.addChild(rankContainer)
  container.addChild(elementContainer)
  container.addChild(seriesContainer)
  container.addChild(btnsContainer)
  // 左侧的右侧
  const inputContainer = await input()
  container.addChild(inputContainer)
  container.position.set(param.value.startWidth, 0)
  return container
}
